<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

   

    <input class="user" type="text">
    <br>
    <input class="pwd" type="text">
    <br>
    <button>登录</button>


    <script src="../js/tools.js"></script>
    <script>

        const oBtn = document.querySelector('button') ;
        const oUser = document.querySelector('.user') ;
        const oPwd = document.querySelector('.pwd') ;

        


        oBtn.onclick = function() {
            // 获取用户名和密码
            const user = oUser.value ;
            const pwd = oPwd.value ;

          
            // 找指定的user是否存在
            const res = getCookie('YYDS_' + user) ;
            console.log(res);

            if(res) {
                if(res === pwd) {
                    // 设置一条cookie   只存用户的名字
                    setCookie('LOGIN_USER' , user) ;
                    location.href = './05list.html' ;
                } else {
                    alert('密码错误')
                }
            } else {
                alert('用户名不存在') ;
            }

        }

    </script>
    
</body>
</html>